home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
dev
/
c
/
sas_c_emacs_b3.lha
/
sc_emacs.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-03-21
|
3KB
|
123 lines
/*
* FILE
* sc_emacs.rexx
*
* DESCRIPTION
* Simple handler between GNUEmacs and SCMSG.
*
* This program is used when SCMSG calls emacs. (When EMACS
* asks SCMSG for information it can do it directly.)
*
* AUTHOR
* Anders Lindgren, d91ali@csd.uu.se
*
* HISTORY
* 93-xxx-xx ALi * Program written
* 94-Mar-21 ALi * zero2str removed as SCMSG now sends correct strings.
* * The Emacs window is moved to the front.
* * One extra 'a'x was added to the end of the GOTOFILE
* line. Make sure that a corresponding options file
* for SCMSG is used.
*/
if ~Show('L','rexxsupport.library') then do
if ~AddLib('rexxsupport.library',0,-30,0) then do
say 'Unable to open rexxsupport.library'
exit 20
end
end
if ~Show('L','slashquote.library') then do
if ~AddLib('slashquote.library',0,-30,0) then do
say 'Unable to open slashquote.library'
exit 20
end
end
port = 'SC_EMACS'
if ~OpenPort(port) then do
say 'Error while opening port' port
exit 20
end
/* Start emacs if it's not already running */
if show('p', 'EMACS1') = 0 then do
address command 'emacs'
delay(1100)
end
quit=0
do until quit
call WaitPkt(port)
pkt = GetPkt(port)
if pkt = Null() then do
iterate
end
msg = getarg(pkt, 0)
/* The 'a'x:s are used as placeholders only */
parse VALUE msg WITH cmd line 'a'x errnum 'a'x,
class 'a'x file 'a'x text 'a'x
retcode = 20
select
when cmd = 'QUIT' then do
retcode = 0
quit = 1
end
when cmd = 'GOTOLINE' then do
/*
* This is a no-op, since everything is
* baked into GOTOFILE
*/
retcode = 0
end
when cmd = 'GOTOFILE' then do
/*
* Undocumented feature: SCMSG quotes filenames
* and texts which contains spaces. VERY STUPID!
* How can a call be made to emacs without
* extensive parsing?
*/
if words(file) > 1 then do
file=substr(file,2,length(file)-2)
end
if words(text) > 1 then do
text=substr(text,2,length(text)-2)
end
/*
* Emacs can't handle quotes in strings as they are
* treated as the end of the string.
* To overcome this all quotes and slashes are escaped
* by a slash.
*/
msg = '(sas-c-view-message ',
slashquote(file) line slashquote(text),
slashquote(class) errnum')'
/* call writeln(stderr, msg) */
address 'EMACS1' '(amiga-window-to-front)'
address 'EMACS1' '(amiga-activate-window)'
address 'EMACS1' msg
retcode = 0
end
otherwise nop
end
call Reply(pkt,retcode)
end
ClosePort(port)